package daikon;


public class ConcordEnter {
	//private String pptName;
	private volatile int hashCode = 0;
	private ValueTuple vt;
	public int nonce;
	//public Map<ValueTuple, ValueTuple> valueTupleWithConcord;
	
	public ValueTuple getVt() {
		return vt;
	}

	public void setVt(ValueTuple vt) {
		this.vt = vt;
	}

	public ConcordEnter(ValueTuple vt, int nonce) {
		this.vt = vt;
		this.nonce = nonce;
	}

	public boolean equals(Object obj) {
        if(this == obj) {
            return true;
        }
        if (!(obj instanceof ConcordEnter)) {
            return false; 
        }
        ConcordEnter concordenter = (ConcordEnter)obj;
        Object[] cvt = concordenter.getVt().vals;
        for(int i=0; i<vt.vals.length; i++) {
        	if(vt.vals[i]==null && vt.vals[i]==null)
        		continue;
        	if(vt.vals[i]==null && vt.vals[i]!=null)
        		continue;
        	if(!vt.vals[i].equals(cvt[i]))
        		return false;
        }
        if(nonce != concordenter.nonce)
        	return false;
        return true;   
    }
 
    public int hashCode () {
        final int multiplier = 23;
        if (hashCode == 0) {
            int code = 133;
            for(int i=0; i<vt.vals.length; i++) {
            	if(vt.vals[i] != null)
            		code = multiplier * code + vt.vals[i].hashCode();
            }
            hashCode = code;
        }
        return hashCode;
    }
}
